package org.qqcui.designpattern.patterns.builder.builder.director;

import org.qqcui.designpattern.patterns.builder.builder.builder.HouseBuilder;
import org.qqcui.designpattern.patterns.builder.builder.product.House;

/**
 * 建造房屋的指挥者，指挥者角色
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022/4/28 16:06
 **/
public class HouseDirector {

    private HouseBuilder builder;

    /**
     * 构造器注入
     * @param builder
     */
    public HouseDirector(HouseBuilder builder) {
        this.builder = builder;
    }

    /**
     * set方式注入
     * @param builder
     */
    public void setHouseBuilder(HouseBuilder builder) {
        this.builder = builder;
    }

    public House constructHouse() {
        builder.buildBasic();
        builder.buildWalls();
        builder.roofed();
        return builder.buildHouse();
    }
}
